

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>aml.node — Basic node types &mdash; AML v0.4.3 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '0.4.3',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="AML v0.4.3 documentation" href="../index.html" />
    <link rel="up" title="aml — Simple interface to the AML Markup Language" href="../aml.html" />
    <link rel="next" title="aml.parser — Simple AML parser" href="parser.html" />
    <link rel="prev" title="aml — Simple interface to the AML Markup Language" href="../aml.html" /> 
  </head>
  <body>
</div>

    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="parser.html" title="aml.parser — Simple AML parser"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="../aml.html" title="aml — Simple interface to the AML Markup Language"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">AML home</a>&nbsp;|&nbsp;</li>
        <li><a href="../contents.html">Documentation</a>&raquo;</li>

          <li><a href="../aml.html" accesskey="U"><tt class="docutils literal docutils literal docutils literal"><span class="pre">aml</span></tt> &#8212; Simple interface to the AML Markup Language</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-aml.node">
<span id="aml-node-basic-node-types"></span><h1><a class="reference internal" href="#module-aml.node" title="Basic node types."><tt class="xref py py-mod docutils literal"><span class="pre">aml.node</span></tt></a> &#8212; Basic node types<a class="headerlink" href="#module-aml.node" title="Permalink to this headline">¶</a></h1>
<p>A <a class="reference internal" href="#aml.node.Node" title="aml.node.Node"><tt class="xref py py-class docutils literal"><span class="pre">Node</span></tt></a> object represents a node in an aml document.</p>
<dl class="class">
<dt id="aml.node.Node">
<em class="property">class </em><tt class="descclassname">aml.node.</tt><tt class="descname">Node</tt><big>(</big><em>name</em><span class="optional">[</span>, <em>attributes</em><span class="optional">[</span>, <em>children</em><span class="optional">]</span><span class="optional">]</span><big>)</big><a class="headerlink" href="#aml.node.Node" title="Permalink to this definition">¶</a></dt>
<dd><p><em>name</em> must be a string. <em>attributes</em> may be <tt class="xref docutils literal"><span class="pre">None</span></tt>, or an instance of
a <tt class="xref py py-class docutils literal"><span class="pre">dict</span></tt>. <em>children</em> may be <tt class="xref docutils literal"><span class="pre">None</span></tt> or, an instance of a
<tt class="xref py py-class docutils literal"><span class="pre">list</span></tt>.</p>
<dl class="attribute">
<dt id="aml.node.Node.name">
<tt class="descname">name</tt><a class="headerlink" href="#aml.node.Node.name" title="Permalink to this definition">¶</a></dt>
<dd><p>Contains the name of the instance.</p>
</dd></dl>

<dl class="attribute">
<dt id="aml.node.Node.parent">
<tt class="descname">parent</tt><a class="headerlink" href="#aml.node.Node.parent" title="Permalink to this definition">¶</a></dt>
<dd><p>A reference to the parent node. Is set automaticaly by <a class="reference internal" href="#aml.node.Node.append" title="aml.node.Node.append"><tt class="xref py py-meth docutils literal"><span class="pre">append()</span></tt></a> and
<a class="reference internal" href="#aml.node.Node.insert" title="aml.node.Node.insert"><tt class="xref py py-meth docutils literal"><span class="pre">insert()</span></tt></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="aml.node.Node.first_child">
<tt class="descname">first_child</tt><a class="headerlink" href="#aml.node.Node.first_child" title="Permalink to this definition">¶</a></dt>
<dd><p>A feference to the first element in <a class="reference internal" href="#aml.node.Node.children" title="aml.node.Node.children"><tt class="xref py py-attr docutils literal"><span class="pre">children</span></tt></a>. Is set automaticaly
by <a class="reference internal" href="#aml.node.Node.append" title="aml.node.Node.append"><tt class="xref py py-meth docutils literal"><span class="pre">append()</span></tt></a> and <a class="reference internal" href="#aml.node.Node.insert" title="aml.node.Node.insert"><tt class="xref py py-meth docutils literal"><span class="pre">insert()</span></tt></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="aml.node.Node.last_child">
<tt class="descname">last_child</tt><a class="headerlink" href="#aml.node.Node.last_child" title="Permalink to this definition">¶</a></dt>
<dd><p>A reference to the last element in <a class="reference internal" href="#aml.node.Node.children" title="aml.node.Node.children"><tt class="xref py py-attr docutils literal"><span class="pre">children</span></tt></a>. Is set automaticaly
by <a class="reference internal" href="#aml.node.Node.append" title="aml.node.Node.append"><tt class="xref py py-meth docutils literal"><span class="pre">append()</span></tt></a> and <a class="reference internal" href="#aml.node.Node.insert" title="aml.node.Node.insert"><tt class="xref py py-meth docutils literal"><span class="pre">insert()</span></tt></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="aml.node.Node.attributes">
<tt class="descname">attributes</tt><a class="headerlink" href="#aml.node.Node.attributes" title="Permalink to this definition">¶</a></dt>
<dd><p>A <tt class="xref py py-class docutils literal"><span class="pre">dict</span></tt> containing the attributes of the instance.</p>
</dd></dl>

<dl class="attribute">
<dt id="aml.node.Node.children">
<tt class="descname">children</tt><a class="headerlink" href="#aml.node.Node.children" title="Permalink to this definition">¶</a></dt>
<dd><p>A <tt class="xref py py-class docutils literal"><span class="pre">list</span></tt> containing the children of the instance.</p>
</dd></dl>

<dl class="describe">
<dt>
<tt class="descname">len(n)</tt></dt>
<dd><p>Return the number childs of the node <em>n</em>.</p>
</dd></dl>

<dl class="describe">
<dt>
<tt class="descname">iter(n)</tt></dt>
<dd><p>Return an iterator over the childs of the node.</p>
</dd></dl>

<dl class="describe">
<dt>
<tt class="descname">bool(n)</tt></dt>
<dd><p>Return <tt class="xref docutils literal"><span class="pre">True</span></tt> if <em>n</em>&#8216;s <a class="reference internal" href="#aml.node.Node.children" title="aml.node.Node.children"><tt class="xref py py-attr docutils literal"><span class="pre">children</span></tt></a> or <a class="reference internal" href="#aml.node.Node.attributes" title="aml.node.Node.attributes"><tt class="xref py py-attr docutils literal"><span class="pre">attributes</span></tt></a> not
empty else <tt class="xref docutils literal"><span class="pre">False</span></tt>.</p>
</dd></dl>

<dl class="describe">
<dt>
<tt class="descname">n[name]</tt></dt>
<dd><p>Return the attribute of <em>n</em> with the name <em>name</em>. Raises <tt class="xref py py-exc docutils literal"><span class="pre">KeyError</span></tt>
if <em>name</em> is not in <em>n</em>&#8216;s <a class="reference internal" href="#aml.node.Node.attributes" title="aml.node.Node.attributes"><tt class="xref py py-attr docutils literal"><span class="pre">attributes</span></tt></a>.</p>
</dd></dl>

<dl class="describe">
<dt>
<tt class="descname">n[name] = value</tt></dt>
<dd><p>Set <tt class="docutils literal"><span class="pre">n[name]</span></tt> to <em>value</em>. <em>value</em> can be a  instance of <tt class="xref py py-class docutils literal"><span class="pre">str</span></tt>,
<tt class="xref py py-class docutils literal"><span class="pre">int</span></tt> or <tt class="xref py py-class docutils literal"><span class="pre">float</span></tt>.</p>
</dd></dl>

<dl class="describe">
<dt>
<tt class="descname">del n[name]</tt></dt>
<dd><p>Remove <tt class="docutils literal"><span class="pre">n[name]</span></tt> from <em>n</em>&#8216;s <tt class="xref py py-attr docutils literal"><span class="pre">attributes.</span> <span class="pre">Raises</span> <span class="pre">:exc:`KeyError</span></tt>
if <em>name</em> is not in <em>n</em>&#8216;s <a class="reference internal" href="#aml.node.Node.attributes" title="aml.node.Node.attributes"><tt class="xref py py-attr docutils literal"><span class="pre">attributes</span></tt></a>.</p>
</dd></dl>

<dl class="describe">
<dt>
<tt class="descname">n1 in n2</tt></dt>
<dd><p>Return <tt class="xref docutils literal"><span class="pre">True</span></tt> if the node <em>n1</em> is a child of the node <em>n2</em> else
<tt class="xref docutils literal"><span class="pre">False</span></tt></p>
</dd></dl>

<dl class="method">
<dt id="aml.node.Node.append">
<tt class="descname">append</tt><big>(</big><em>node</em><big>)</big><a class="headerlink" href="#aml.node.Node.append" title="Permalink to this definition">¶</a></dt>
<dd><p>Append <em>node</em> to <a class="reference internal" href="#aml.node.Node.children" title="aml.node.Node.children"><tt class="xref py py-attr docutils literal"><span class="pre">children</span></tt></a> of the instance. <em>node</em> must be an
instance of <a class="reference internal" href="#aml.node.Node" title="aml.node.Node"><tt class="xref py py-class docutils literal"><span class="pre">Node</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="aml.node.Node.insert">
<tt class="descname">insert</tt><big>(</big><em>index</em>, <em>node</em><big>)</big><a class="headerlink" href="#aml.node.Node.insert" title="Permalink to this definition">¶</a></dt>
<dd><p>Insert <em>node</em> at <em>index</em> to <a class="reference internal" href="#aml.node.Node.children" title="aml.node.Node.children"><tt class="xref py py-attr docutils literal"><span class="pre">children</span></tt></a>. <em>index</em> must be an
instance of <tt class="xref py py-class docutils literal"><span class="pre">int</span></tt>, <em>node</em> must be an instance of <a class="reference internal" href="#aml.node.Node" title="aml.node.Node"><tt class="xref py py-class docutils literal"><span class="pre">Node</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="aml.node.Node.remove">
<tt class="descname">remove</tt><big>(</big><em>node</em><big>)</big><a class="headerlink" href="#aml.node.Node.remove" title="Permalink to this definition">¶</a></dt>
<dd><p>Removes <em>node</em> from <a class="reference internal" href="#aml.node.Node.children" title="aml.node.Node.children"><tt class="xref py py-attr docutils literal"><span class="pre">children</span></tt></a>. <em>node</em> must be an instance of
<a class="reference internal" href="#aml.node.Node" title="aml.node.Node"><tt class="xref py py-class docutils literal"><span class="pre">Node</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="aml.node.Node.has_attr">
<tt class="descname">has_attr</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#aml.node.Node.has_attr" title="Permalink to this definition">¶</a></dt>
<dd><p>Test for the presence of <em>name</em> in the node&#8217;s <a class="reference internal" href="#aml.node.Node.attributes" title="aml.node.Node.attributes"><tt class="xref py py-attr docutils literal"><span class="pre">attributes</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt>
<tt class="descname">get_attr(name[, default]):</tt></dt>
<dd><p>Return the value for <em>name</em> if <em>name</em> is in <a class="reference internal" href="#aml.node.Node.attributes" title="aml.node.Node.attributes"><tt class="xref py py-attr docutils literal"><span class="pre">attributes</span></tt></a>, else
<em>default</em>. If <em>default</em> is not given, it defaults to <tt class="xref docutils literal"><span class="pre">None</span></tt>, so that
this method never raises a <tt class="xref py py-exc docutils literal"><span class="pre">KeyError</span></tt>.</p>
</dd></dl>

<dl class="method">
<dt id="aml.node.Node.iter_attrs">
<tt class="descname">iter_attrs</tt><big>(</big><big>)</big><a class="headerlink" href="#aml.node.Node.iter_attrs" title="Permalink to this definition">¶</a></dt>
<dd><p>Return an iterator over the node&#8217;s <tt class="docutils literal"><span class="pre">(name,</span> <span class="pre">value)</span></tt> attribute pairs.</p>
</dd></dl>

</dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h4>Previous topic</h4>
  <p class="topless"><a href="../aml.html"
                        title="previous chapter"><tt class="docutils literal docutils literal"><span class="pre">aml</span></tt> &#8212; Simple interface to the AML Markup Language</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="parser.html"
                        title="next chapter"><tt class="docutils literal"><span class="pre">aml.parser</span></tt> &#8212; Simple AML parser</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/aml/node.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="parser.html" title="aml.parser — Simple AML parser"
             >next</a> |</li>
        <li class="right" >
          <a href="../aml.html" title="aml — Simple interface to the AML Markup Language"
             >previous</a> |</li>
        <li><a href="../index.html">AML home</a>&nbsp;|&nbsp;</li>
        <li><a href="../contents.html">Documentation</a>&raquo;</li>

          <li><a href="../aml.html" ><tt class="docutils literal docutils literal docutils literal"><span class="pre">aml</span></tt> &#8212; Simple interface to the AML Markup Language</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2009, Bjoern Schulz.
      Last updated on Oct 31, 2010.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.1.
    </div>
  </body>
</html>